<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加商品</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Arial', sans-serif;
        }

        .container {
            margin-top: 50px;
            background-color: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .btn-primary {
            background-color: #007bff;
            border: none;
            border-radius: 5px;
        }

        .btn-primary:hover {
            background-color: #0056b3;
        }

        .btn-secondary {
            background-color: #6c757d;
            border: none;
            border-radius: 5px;
        }

        .btn-secondary:hover {
            background-color: #5a6268;
        }
    </style>
</head>
<body>
<div class="container">
    <h1 class="mb-4">添加商品</h1>
    <form method="post" action="{% url 'product_add' %}">
        {% csrf_token %}
        <!-- name 字段 -->
        <div class="form-group">
            <label for="{{ form.name.id_for_label }}" class="form-label">商品名称</label>
            <input type="text" name="name" id="id_name" class="form-control"
                   value="{{ form.name.value|default_if_none:'' }}" required>
            {% if form.name.errors %}
                <div class="text-danger">
                    {{ form.name.errors }}
                </div>
            {% endif %}
        </div>

        <!-- remark 字段 -->
        <div class="form-group">
            <label for="{{ form.remark.id_for_label }}" class="form-label">备注</label>
            <input type="text" name="remark" id="id_remark" class="form-control">
            {% if form.remark.errors %}
                <div class="text-danger">
                    {{ form.remark.errors }}
                </div>
            {% endif %}
        </div>

        <!-- price 字段 -->
        <div class="form-group">
            <label for="{{ form.price.id_for_label }}" class="form-label">价格</label>
            <input type="number" name="price" id="id_price" class="form-control">
            {% if form.price.errors %}
                <div class="text-danger">
                    {{ form.price.errors }}
                </div>
            {% endif %}
        </div>

        <!-- inventory_num 字段  step="1" 控制整数-->
        <div class="form-group">
            <label for="{{ form.inventory_num.id_for_label }}" class="form-label">库存数量</label>
            <input type="number" step="1" name="inventory_num" id="id_inventory_num" class="form-control">
            {% if form.inventory_num.errors %}
                <div class="text-danger">
                    {{ form.price.errors }}
                </div>
            {% endif %}
        </div>
        <button type="submit" class="btn btn-primary">保存</button>
        <a href="{% url 'main' %}" class="btn btn-secondary">取消</a>
    </form>
</div>
</body>
</html>